import { getDictLabel } from "@/utils/utils";
// 不可以使用store，异步的原因会导致问题
import baseService from "@/service/baseService";
let dicts: any;
const fetchDicts = async () => {
  const { data } = await baseService.get("/sys/dict/type/all");
  dicts = data;
};
fetchDicts();
export const useDict = (dictType: string, dictValue: number): string | number => {
  let handleFun = null;
  dicts.length ? (handleFun = getDictLabel(dicts, dictType, dictValue)) : "";
  return handleFun as string | number;
};
